$(function(){
  let form=layui.form
  form.verify({
    pwd: [
      /^[\S]{6,15}$/,
      '只能填写6~15位非空字符串'
    ],
    newpwd:function(value) {
      let v1 = $('[name=oldPwd]').val()
      if (value == v1) {
        return '新密码不能与原密码相同'
      }
    },
    repwd:function(value) {
      let v2 = $('[name=newPwd]').val()
      if (value !== v2) {
        return '两次密码不一致'
      }
    }
  })


  $('form').on('submit', function (e) {
   e.preventDefault()
 axios({
   url:'/my/updatepwd',
   method:'post',
   data:$(this).serialize()
 
 }).then(res=>{
   //成功回调
   console.log(res)
   if (res.data.status != 0) {
     return layui.layer.msg(res.data.message)
   }
   layui.layer.msg('恭喜修改密码成功')
   $('form')[0].reset()
   window.parent.location.href='/login.html'
 })
 }) 



})